#include <iostream>
#include <vector>
#include <string>

using namespace std;

int findCommonDivisor(int m, int s){
    int cd = 1, n = s > 0 ? s : -s;
    for(int i = 1; i <= n ;i++){
		if((n % i == 0) && (m % i == 0)){
			if(i > cd){
				cd = i;              
			}
		}
	}
    return cd;
}

int gcd(int a, int b){
    int tmp;
    while(b > 0){
        tmp = a % b;
        a = b;
        b = tmp;
    }
    return a;
}


string fractionAddition(string expression) {
    int ret = 0, M = 7560, i = expression[0] == '-' ? 1 : 0, signalD = expression.find('/'), signal = expression[0] == '-' ? -1 : 1; // signalN = expression.find("+");
    while(i < expression.size()){
        int s = signal * stoi(expression.substr(i, signalD-i));
        i = signalD;
        while(expression[i] != '+' && expression[i] != '-' && i < expression.size()) i++;
        // int m = stoi(expression.substr(signalD+1, i-signalD-1));
        ret += s * (M / stoi(expression.substr(signalD+1, i-signalD-1)));
        signal = expression[i++] == '-' ? -1 : 1;
        signalD = expression.find('/', i);
    }
    if(ret == 0) return "0/1";
    // int cd = findCommonDivisor(M, ret);
    int g = gcd(abs(ret), M); // 辗转相除法快速获取最大公约数
    return to_string(ret/g) + "/" + to_string(M/g);
}

int main(){
    string expression = "-1/1+2/5+3/2+1/9+8/1-2/1+10/3-7/5+3/8+3/1";
    cout << fractionAddition(expression) << endl;
    return 0;
}
